<!DOCTYPE html>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>

<p>This tests for a drag select crasher.</p>
<div id="div" contenteditable="true"><span id="start">Start here.</span> <input id="end" type="text"></div>
This uses the eventSender to perform a drag select.  To run it manually, mouse down over 'start here' and drag to the left, over the input field.

<script>
test(function() {
    if (!window.testRunner)
        return;
    var div = document.getElementById("div");
    var sel = window.getSelection();
    sel.collapse(div, 0);
    
    var start = document.getElementById("start");
    var startx = -8 + start.offsetLeft + start.offsetWidth / 2;
    var starty = start.offsetTop + start.offsetHeight / 2;
    eventSender.mouseMoveTo(startx, starty);
    eventSender.mouseDown();

    var end = document.getElementById("end");
    endx = -8 + end.offsetLeft + end.offsetWidth / 2;
    endy = end.offsetTop + end.offsetHeight / 2;

    var steps = 20;
    for (var i = 1; i <= steps; i++) {
        eventSender.mouseMoveTo(startx + Math.abs(startx - endx) * (i / steps), starty + Math.abs(starty - endy) * (i / steps));
    }

    eventSender.mouseMoveTo(endx, endy);
    eventSender.mouseUp();
}, "Passes if no crash");
</script>
